//
//  VistorTableViewController.swift
//  01-WeiBo
//
//  Created by 李晓东 on 17/6/25.
//  Copyright © 2017年 PeanutXu. All rights reserved.
//

import UIKit

class VistorTableViewController: UITableViewController {

    private let userLogin = UserAccountViewModel.shareUserAccount.isLogon
    var vistorView : VistorView?
    
    override func loadView() {
        userLogin  ? super.loadView() : self.showView()
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        UINavigationBar.appearance().tintColor = UIColor.orange
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .plain, target: self, action: #selector(VistorTableViewController.visitorViewDidRegister))
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: .plain, target: self, action: #selector(visitorViewDidLogin))
    }

    private func showView(){
        vistorView = VistorView()
        vistorView?.delegate = self
        view = vistorView
        
    }

}


extension VistorTableViewController:VistorViewDelegate{
    func visitorViewDidRegister() {
        print("Im registed")
    }
    
    func visitorViewDidLogin() {
        let authController = OAuthViewController()
        let naviController = UINavigationController(rootViewController: authController)
        
        present(naviController, animated: true, completion: nil)
    }
    
    
}
